/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('msha', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model GetUnitTypeAndUnitDefinesRequest {
  unitType?: string(name='UnitType', description='业务类型唯一标识'),
  currentPage?: int32(name='CurrentPage', description='当前页面，从1开始，最大限制为100'),
  pageSize?: int32(name='PageSize', description='分页大小，最大限制为200'),
}

model GetUnitTypeAndUnitDefinesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      gmtCreate?: long(name='gmtCreate', description='创建业务类型的时间'),
      unitType?: string(name='unitType', description='业务类型唯一标识'),
      name?: string(name='name', description='业务类型名称'),
      units?: [ 
        {
          gmtCreate?: long(name='gmtCreate', description='单元创建时间'),
          unitFlag?: string(name='unitFlag', description='单元唯一标识'),
          unitName?: string(name='unitName', description='单元名称'),
          regionId?: string(name='regionId', description='地域ID'),
          unitType?: string(name='unitType', description='业务类型唯一标识'),
          zoneIds?: [ string ](name='zoneIds', description='可用区ID列表'),
          unitRoles?: [ string ](name='unitRoles', description='单元角色列表。值为 中心单元：center，副中心单元：standby，普通多活单元：normal'),
          cells?: [ 
            {
              gmtCreate?: long(name='gmtCreate', description='单元格创建时间'),
              regionId?: string(name='regionId', description='地域ID'),
              zoneIds?: [ string ](name='zoneIds', description='包含的可用区ID列表'),
              unitFlag?: string(name='unitFlag', description='单元唯一标识'),
              cellFlag?: string(name='cellFlag', description='单元格唯一标识'),
              cellName?: string(name='cellName', description='单元格名称'),
              unitType?: string(name='unitType', description='业务类型唯一标识'),
              flowIsolated?: boolean(name='flowIsolated', description='是否流量隔离。开启流量隔离，单元格流量比例固定为0，需要单独配置引流规则。'),
            }
          ](name='cells', description='包含的单元格定义列表'),
        }
      ](name='units', description='包含的单元定义列表'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetUnitTypeAndUnitDefinesResponse = {
  headers: map[string]string(name='headers'),
  body: GetUnitTypeAndUnitDefinesResponseBody(name='body'),
}

async function getUnitTypeAndUnitDefinesWithOptions(request: GetUnitTypeAndUnitDefinesRequest, runtime: Util.RuntimeOptions): GetUnitTypeAndUnitDefinesResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetUnitTypeAndUnitDefines', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getUnitTypeAndUnitDefines(request: GetUnitTypeAndUnitDefinesRequest): GetUnitTypeAndUnitDefinesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUnitTypeAndUnitDefinesWithOptions(request, runtime);
}

model GetRpcAppFlowRuleSummarysRequest {
  unitFlag?: string(name='UnitFlag', description='单元'),
  mshaTenantId?: string(name='MshaTenantId', description='命名空间ID'),
  appName?: string(name='AppName', description='应用名'),
  status?: string(name='Status', description='生效状态.未配置,创建未生效,修改未生效,删除未生效,推送中,生效中,生效失败'),
  pageNum?: long(name='PageNum', description='当前页码'),
  pageSize?: long(name='PageSize', description='页面大小'),
  rpcType?: string(name='RpcType', description='rpc 类型。sc, dubbo'),
}

model GetRpcAppFlowRuleSummarysResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      status?: string(name='status', description='SpringCloud应用规则状态。未配置,创建未生效,修改未生效,删除未生效,推送中,生效中,生效失败'),
      pushPlanId?: string(name='pushPlanId', description='推送计划的ID，可以查询推送计划'),
      appName?: string(name='appName', description='应用名称'),
      activeCount?: long(name='activeCount', description='生效的ItemRule的数量'),
      cellFlags?: [ string ](name='cellFlags', description='引流的单元格列表'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetRpcAppFlowRuleSummarysResponse = {
  headers: map[string]string(name='headers'),
  body: GetRpcAppFlowRuleSummarysResponseBody(name='body'),
}

async function getRpcAppFlowRuleSummarysWithOptions(request: GetRpcAppFlowRuleSummarysRequest, runtime: Util.RuntimeOptions): GetRpcAppFlowRuleSummarysResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetRpcAppFlowRuleSummarys', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getRpcAppFlowRuleSummarys(request: GetRpcAppFlowRuleSummarysRequest): GetRpcAppFlowRuleSummarysResponse {
  var runtime = new Util.RuntimeOptions{};
  return getRpcAppFlowRuleSummarysWithOptions(request, runtime);
}

model AddSpringCloudFlowItemRuleRequest {
  requestData?: {
    mshaTenantId?: string(name='mshaTenantId', description='多活命名空间ID'),
    unitFlag?: string(name='unitFlag', description='单元'),
    appName?: string(name='appName', description='应用名称'),
    transportEnable?: boolean(name='transportEnable', description='是否开启染色'),
    priority?: long(name='priority', description='优先级'),
    name?: string(name='name', description='名称'),
    uriList?: [ string ](name='uriList', description='URI列表'),
    active?: boolean(name='active', description='是否生效，该规则在数据面是否生效'),
    queryMatcher?: [ 
      {
        key?: string(name='key', description='键值'),
        matchType?: string(name='matchType', description='匹配类型。in,notIn,between,>,>=,<,<=,='),
        values?: [ string ](name='values', description='值的集合'),
        extractType?: string(name='extractType', description='提取类型。mod,whole'),
        modValue?: long(name='modValue', description='模数'),
      }
    ](name='queryMatcher', description='Http query param匹配'),
    headerMatcher?: [ 
      {
        key?: string(name='key', description='键值'),
        matchType?: string(name='matchType', description='匹配类型。in,notIn,between,>,>=,<,<=,='),
        values?: [ string ](name='values', description='值的集合'),
        extractType?: string(name='extractType', description='提取类型。mod,whole'),
        modValue?: long(name='modValue', description='模数'),
      }
    ](name='headerMatcher', description='HTTP header匹配规则'),
    cellWeightList?: [ 
      {
        cellFlag?: string(name='cellFlag', description='单元格'),
        weight?: string(name='weight', description='引流比例,最多支持小数点后4位。0.0000～1.0000'),
      }
    ](name='cellWeightList'),
    effective?: boolean(name='effective', description='是否立即生效，MSHA将立即推送该规则'),
  }(name='requestData'),
}

model AddSpringCloudFlowItemRuleShrinkRequest {
  requestDataShrink?: string(name='requestData'),
}

model AddSpringCloudFlowItemRuleResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: {
    pushPlanId?: long(name='pushPlanId'),
    ruleItemId?: long(name='ruleItemId'),
  }(name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model AddSpringCloudFlowItemRuleResponse = {
  headers: map[string]string(name='headers'),
  body: AddSpringCloudFlowItemRuleResponseBody(name='body'),
}

async function addSpringCloudFlowItemRuleWithOptions(tmpReq: AddSpringCloudFlowItemRuleRequest, runtime: Util.RuntimeOptions): AddSpringCloudFlowItemRuleResponse {
  Util.validateModel(tmpReq);
  var request = new AddSpringCloudFlowItemRuleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.requestData)) {
    request.requestDataShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.requestData, 'requestData', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('AddSpringCloudFlowItemRule', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function addSpringCloudFlowItemRule(request: AddSpringCloudFlowItemRuleRequest): AddSpringCloudFlowItemRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return addSpringCloudFlowItemRuleWithOptions(request, runtime);
}

model DeleteFlowItemRuleRequest {
  ruleItemId?: [ string ](name='RuleItemId', description='ItemRule返回的ruleItemId'),
  mshaTenantId?: string(name='MshaTenantId', description='命名空间ID'),
  unitFlag?: string(name='UnitFlag', description='单元'),
  effective?: boolean(name='Effective', description='是否立即生效'),
}

model DeleteFlowItemRuleShrinkRequest {
  ruleItemIdShrink?: string(name='RuleItemId', description='ItemRule返回的ruleItemId'),
  mshaTenantId?: string(name='MshaTenantId', description='命名空间ID'),
  unitFlag?: string(name='UnitFlag', description='单元'),
  effective?: boolean(name='Effective', description='是否立即生效'),
}

model DeleteFlowItemRuleResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model DeleteFlowItemRuleResponse = {
  headers: map[string]string(name='headers'),
  body: DeleteFlowItemRuleResponseBody(name='body'),
}

async function deleteFlowItemRuleWithOptions(tmpReq: DeleteFlowItemRuleRequest, runtime: Util.RuntimeOptions): DeleteFlowItemRuleResponse {
  Util.validateModel(tmpReq);
  var request = new DeleteFlowItemRuleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.ruleItemId)) {
    request.ruleItemIdShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.ruleItemId, 'RuleItemId', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DeleteFlowItemRule', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function deleteFlowItemRule(request: DeleteFlowItemRuleRequest): DeleteFlowItemRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteFlowItemRuleWithOptions(request, runtime);
}

model CommitSpringCloudFlowRuleRequest {
  unitFlag?: string(name='UnitFlag', description='单元'),
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  appNames?: [ string ](name='AppNames', description='应用名'),
}

model CommitSpringCloudFlowRuleShrinkRequest {
  unitFlag?: string(name='UnitFlag', description='单元'),
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  appNamesShrink?: string(name='AppNames', description='应用名'),
}

model CommitSpringCloudFlowRuleResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data', description='推送计划的ID'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model CommitSpringCloudFlowRuleResponse = {
  headers: map[string]string(name='headers'),
  body: CommitSpringCloudFlowRuleResponseBody(name='body'),
}

async function commitSpringCloudFlowRuleWithOptions(tmpReq: CommitSpringCloudFlowRuleRequest, runtime: Util.RuntimeOptions): CommitSpringCloudFlowRuleResponse {
  Util.validateModel(tmpReq);
  var request = new CommitSpringCloudFlowRuleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.appNames)) {
    request.appNamesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appNames, 'AppNames', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CommitSpringCloudFlowRule', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function commitSpringCloudFlowRule(request: CommitSpringCloudFlowRuleRequest): CommitSpringCloudFlowRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return commitSpringCloudFlowRuleWithOptions(request, runtime);
}

model GetUserLicenceResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: string(name='data', description='获取阿里云账号在MSHA产品中的Licence值'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetUserLicenceResponse = {
  headers: map[string]string(name='headers'),
  body: GetUserLicenceResponseBody(name='body'),
}

async function getUserLicenceWithOptions(runtime: Util.RuntimeOptions): GetUserLicenceResponse {
  var req = new OpenApi.OpenApiRequest{};
  return doRPCRequest('GetUserLicence', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getUserLicence(): GetUserLicenceResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserLicenceWithOptions(runtime);
}

model CloseSpringCloudFlowRulesRequest {
  unitFlag?: string(name='UnitFlag', description='单元'),
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  appNames?: [ string ](name='AppNames', description='应用名'),
}

model CloseSpringCloudFlowRulesShrinkRequest {
  unitFlag?: string(name='UnitFlag', description='单元'),
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  appNamesShrink?: string(name='AppNames', description='应用名'),
}

model CloseSpringCloudFlowRulesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data', description='推送计划的ID'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model CloseSpringCloudFlowRulesResponse = {
  headers: map[string]string(name='headers'),
  body: CloseSpringCloudFlowRulesResponseBody(name='body'),
}

async function closeSpringCloudFlowRulesWithOptions(tmpReq: CloseSpringCloudFlowRulesRequest, runtime: Util.RuntimeOptions): CloseSpringCloudFlowRulesResponse {
  Util.validateModel(tmpReq);
  var request = new CloseSpringCloudFlowRulesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.appNames)) {
    request.appNamesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appNames, 'AppNames', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CloseSpringCloudFlowRules', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function closeSpringCloudFlowRules(request: CloseSpringCloudFlowRulesRequest): CloseSpringCloudFlowRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return closeSpringCloudFlowRulesWithOptions(request, runtime);
}

model GetNamespaceInfosRequest {
  mshaTenantId?: string(name='MshaTenantId', description='MSHA命名空间ID'),
}

model GetNamespaceInfosResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      gmtCreate?: long(name='gmtCreate', description='命名空间创建时间'),
      mshaTenantId?: string(name='mshaTenantId', description='命名空间ID'),
      mshaTenantName?: string(name='mshaTenantName', description='命名空间名称'),
      unitType?: string(name='unitType', description='业务类型唯一标识'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetNamespaceInfosResponse = {
  headers: map[string]string(name='headers'),
  body: GetNamespaceInfosResponseBody(name='body'),
}

async function getNamespaceInfosWithOptions(request: GetNamespaceInfosRequest, runtime: Util.RuntimeOptions): GetNamespaceInfosResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetNamespaceInfos', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getNamespaceInfos(request: GetNamespaceInfosRequest): GetNamespaceInfosResponse {
  var runtime = new Util.RuntimeOptions{};
  return getNamespaceInfosWithOptions(request, runtime);
}

model GetDomainsRequest {
  mshaTenantId?: string(name='MshaTenantId', description='命名空间ID'),
}

model GetDomainsResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      gmtCreate?: long(name='gmtCreate', description='创建时间'),
      mshaTenantId?: string(name='mshaTenantId', description='命名空间ID'),
      domain?: string(name='domain', description='域名'),
      protocolType?: string(name='protocolType', description='协议类型。值为 http/websocket'),
      redirectType?: string(name='redirectType', description='流量纠错类型。值为 upstream/301/302'),
      configStatus?: string(name='configStatus', description='配置状态。值为 ACTIVE/MODIFIED/REMOVED'),
      accessType?: string(name='accessType', description='接入类型。值为 ip/domain'),
      uris?: [ 
        {
          configStatus?: string(name='configStatus', description='配置状态。值为 ACTIVE/MODIFIED/REMOVED'),
          gmtCreate?: long(name='gmtCreate', description='创建时间'),
          uriPrefix?: string(name='uriPrefix', description='URI前缀'),
          isUnit?: boolean(name='isUnit', description='是否单元化'),
        }
      ](name='uris', description='URI列表'),
      domainType?: string(name='domainType', description='域名类型，值为 单元化域名：unit，强中心域名：center'),
      managerType?: string(name='managerType', description='域名托管方式 ：DNS/GTM/EMPTY'),
      id?: long(name='id', description='域id'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetDomainsResponse = {
  headers: map[string]string(name='headers'),
  body: GetDomainsResponseBody(name='body'),
}

async function getDomainsWithOptions(request: GetDomainsRequest, runtime: Util.RuntimeOptions): GetDomainsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetDomains', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getDomains(request: GetDomainsRequest): GetDomainsResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDomainsWithOptions(request, runtime);
}

model ListDomainUnitCellsRequest {
  domainId?: long(name='DomainId', description='域名Id'),
  mshaTenantId?: string(name='MshaTenantId'),
  unitType?: string(name='UnitType'),
}

model ListDomainUnitCellsResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      id?: long(name='id'),
      isDeleted?: boolean(name='isDeleted', description='是否被删除'),
      gmtCreate?: long(name='gmtCreate', description='创建时间'),
      gmtModified?: long(name='gmtModified', description='修改时间'),
      rootUserId?: string(name='rootUserId', description='主用户'),
      unitFlag?: string(name='unitFlag', description='单元标'),
      unitName?: string(name='unitName', description='单元名'),
      regionId?: string(name='regionId'),
      regionName?: string(name='regionName', description='region名'),
      rootOrgId?: string(name='rootOrgId', description='组织树根结点的rootUserId'),
      unitType?: string(name='unitType', description='单元归属的多活类型'),
      unitOrder?: long(name='unitOrder', description='排序标识'),
      zoneIds?: [ string ](name='zoneIds'),
      unitRoles?: [ string ](name='unitRoles', description='单元角色'),
      cells?: [ 
        {
          id?: long(name='id'),
          isDeleted?: boolean(name='isDeleted'),
          gmtCreate?: long(name='gmtCreate'),
          gmtModified?: long(name='gmtModified'),
          regionId?: string(name='regionId'),
          zoneIds?: [ string ](name='zoneIds'),
          unitFlag?: string(name='unitFlag'),
          cellFlag?: string(name='cellFlag'),
          cellName?: string(name='cellName'),
          cellOrder?: long(name='cellOrder'),
          rootOrgId?: string(name='rootOrgId'),
          unitType?: string(name='unitType'),
          creatorRootUserId?: string(name='creatorRootUserId'),
          flowIsolated?: boolean(name='flowIsolated'),
          hasBackIp?: boolean(name='hasBackIp'),
        }
      ](name='cells', description='单元格'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model ListDomainUnitCellsResponse = {
  headers: map[string]string(name='headers'),
  body: ListDomainUnitCellsResponseBody(name='body'),
}

async function listDomainUnitCellsWithOptions(request: ListDomainUnitCellsRequest, runtime: Util.RuntimeOptions): ListDomainUnitCellsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('ListDomainUnitCells', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function listDomainUnitCells(request: ListDomainUnitCellsRequest): ListDomainUnitCellsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDomainUnitCellsWithOptions(request, runtime);
}

model GetUrisRequest {
  domainId?: long(name='DomainId', description='域名Id'),
}

model GetUrisResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      mshaTenantId?: string(name='mshaTenantId'),
      domainUriDO?: {
        id?: long(name='id'),
        gmtCreate?: long(name='gmtCreate'),
        gmtModified?: long(name='gmtModified'),
        isDeleted?: boolean(name='isDeleted'),
        domainId?: long(name='domainId'),
        uriPrefix?: string(name='uriPrefix'),
        isUnit?: boolean(name='isUnit'),
        configStatus?: string(name='configStatus'),
        uriFrom?: string(name='uriFrom'),
        hasDefaultRouterId?: boolean(name='hasDefaultRouterId'),
      }(name='domainUriDO'),
      uriUpstreamDOs?: [ 
        {
          id?: long(name='id'),
          gmtCreate?: long(name='gmtCreate'),
          gmtModified?: long(name='gmtModified'),
          isDeleted?: boolean(name='isDeleted'),
          domainUriId?: long(name='domainUriId'),
          unitFlag?: string(name='unitFlag'),
          cell?: string(name='cell'),
          backIps?: string(name='backIps'),
        }
      ](name='uriUpstreamDOs'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetUrisResponse = {
  headers: map[string]string(name='headers'),
  body: GetUrisResponseBody(name='body'),
}

async function getUrisWithOptions(request: GetUrisRequest, runtime: Util.RuntimeOptions): GetUrisResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetUris', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getUris(request: GetUrisRequest): GetUrisResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUrisWithOptions(request, runtime);
}

model CloseSpringCloudFlowItemRulesRequest {
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  ruleItemIds?: [ string ](name='ruleItemIds', description='ItemRule的ID'),
}

model CloseSpringCloudFlowItemRulesShrinkRequest {
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  ruleItemIdsShrink?: string(name='ruleItemIds', description='ItemRule的ID'),
}

model CloseSpringCloudFlowItemRulesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data', description='推送计划的ID'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model CloseSpringCloudFlowItemRulesResponse = {
  headers: map[string]string(name='headers'),
  body: CloseSpringCloudFlowItemRulesResponseBody(name='body'),
}

async function closeSpringCloudFlowItemRulesWithOptions(tmpReq: CloseSpringCloudFlowItemRulesRequest, runtime: Util.RuntimeOptions): CloseSpringCloudFlowItemRulesResponse {
  Util.validateModel(tmpReq);
  var request = new CloseSpringCloudFlowItemRulesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.ruleItemIds)) {
    request.ruleItemIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.ruleItemIds, 'ruleItemIds', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CloseSpringCloudFlowItemRules', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function closeSpringCloudFlowItemRules(request: CloseSpringCloudFlowItemRulesRequest): CloseSpringCloudFlowItemRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return closeSpringCloudFlowItemRulesWithOptions(request, runtime);
}

model GetAppInstancesRequest {
  currentPage?: int32(name='CurrentPage', description='当前页码，最小值为1，最大限制为200'),
  pageSize?: int32(name='PageSize', description='页面大小。最大限制为500'),
  regionId?: string(name='RegionId', description='地域ID'),
  deviceType?: string(name='DeviceType', description='部署类型，取值 Docker/ECS， 不传默认查询全部'),
  appName?: string(name='AppName', description='应用名称'),
  instanceId?: string(name='InstanceId', description='ECS实例ID'),
  ip?: string(name='Ip', description='宿主机ECS IP或K8S私网IP'),
  unitFlag?: string(name='UnitFlag', description='单元唯一标识'),
  cellFlag?: string(name='CellFlag', description='单元格唯一标识'),
  zoneId?: string(name='ZoneId', description='可用区ID'),
  mshaTenantId?: string(name='MshaTenantId', description='MSHA命名空间ID'),
}

model GetAppInstancesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      hostIp?: string(name='HostIp', description='宿主机IP'),
      vpcId?: string(name='VpcId', description='VPC网络ID'),
      privateIp?: string(name='PrivateIp', description='K8s私网IP'),
      deviceType?: string(name='DeviceType', description='部署类型，取值 Docker/ECS'),
      instanceId?: string(name='InstanceId', description='ECS实例ID'),
      unitFlag?: string(name='UnitFlag', description='单元标识'),
      lastHeartBeatTime?: long(name='LastHeartBeatTime', description='最近一次心跳上报时间'),
      appName?: string(name='AppName', description='应用名称'),
      version?: string(name='Version', description='MSHA-SDK/Agent版本号'),
      region?: long(name='Region', description='地域ID'),
      zone?: string(name='Zone', description='可用区ID'),
      cellFlag?: string(name='CellFlag', description='单元格标识'),
      namespaces?: [ string ](name='Namespaces', description='应用所对应的命名空间ID列表'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetAppInstancesResponse = {
  headers: map[string]string(name='headers'),
  body: GetAppInstancesResponseBody(name='body'),
}

async function getAppInstancesWithOptions(request: GetAppInstancesRequest, runtime: Util.RuntimeOptions): GetAppInstancesResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetAppInstances', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getAppInstances(request: GetAppInstancesRequest): GetAppInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAppInstancesWithOptions(request, runtime);
}

model GetSpringCloudFlowItemRulesRequest {
  unitFlag?: string(name='UnitFlag', description='单元'),
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间ID'),
  appName?: string(name='AppName', description='应用名'),
}

model GetSpringCloudFlowItemRulesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      ruleItemId?: long(name='ruleItemId', description='该匹配规则的ID'),
      name?: string(name='name', description='名称'),
      active?: boolean(name='active', description='是否生效'),
      transportEnable?: boolean(name='transportEnable', description='是否开启流量染色'),
      priority?: int32(name='priority', description='优先级'),
      queryMatcher?: [ 
        {
          key?: string(name='Key', description='键值'),
          matchType?: string(name='MatchType', description='匹配类型。in,notIn,between,>,>=,<,<=,='),
          values?: [ string ](name='Values', description='值的集合'),
          extractType?: string(name='ExtractType', description='提取类型。mod,whole'),
          modValue?: long(name='ModValue', description='模数'),
        }
      ](name='queryMatcher', description='HTTP query匹配条件'),
      headerMatcher?: [ 
        {
          key?: string(name='Key', description='键值'),
          matchType?: string(name='MatchType', description='匹配类型。in,notIn,between,>,>=,<,<=,='),
          values?: [ string ](name='Values', description='值的集合'),
          extractType?: string(name='ExtractType', description='提取类型。mod,whole'),
          modValue?: long(name='ModValue', description='模数'),
        }
      ](name='headerMatcher', description='HTTP header匹配条件'),
      uriList?: [ string ](name='uriList', description='URI的列表'),
      cellWeightList?: [ 
        {
          cellFlag?: string(name='cellFlag', description='单元格'),
          weight?: string(name='weight', description='引流比例。0.0000～1，最多支持小数点后4位'),
        }
      ](name='cellWeightList', description='单元格引流比例'),
      status?: string(name='status', description='状态.未配置,创建未生效,修改未生效,删除未生效,推送中,生效中,生效失败'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetSpringCloudFlowItemRulesResponse = {
  headers: map[string]string(name='headers'),
  body: GetSpringCloudFlowItemRulesResponseBody(name='body'),
}

async function getSpringCloudFlowItemRulesWithOptions(request: GetSpringCloudFlowItemRulesRequest, runtime: Util.RuntimeOptions): GetSpringCloudFlowItemRulesResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetSpringCloudFlowItemRules', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getSpringCloudFlowItemRules(request: GetSpringCloudFlowItemRulesRequest): GetSpringCloudFlowItemRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSpringCloudFlowItemRulesWithOptions(request, runtime);
}

model GetDomainAndUriResourcesRequest {
  currentPage?: int32(name='CurrentPage', description='当前页码，最小值为1，最大限制为200'),
  pageSize?: int32(name='PageSize', description='页面大小。最大限制为500'),
  domain?: string(name='Domain', description='域名'),
  mshaTenantId?: string(name='MshaTenantId', description='命名空间ID'),
}

model GetDomainAndUriResourcesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: [ 
    {
      gmtCreate?: long(name='gmtCreate', description='创建时间'),
      mshaTenantId?: string(name='mshaTenantId', description='命名空间ID'),
      domain?: string(name='domain', description='域名'),
      protocolType?: string(name='protocolType', description='协议类型。值为 http/websocket'),
      redirectType?: string(name='redirectType', description='流量纠错类型。值为 upstream/301/302'),
      configStatus?: string(name='configStatus', description='配置状态。值为 ACTIVE/MODIFIED/REMOVED'),
      accessType?: string(name='accessType', description='接入类型。值为 ip/domain'),
      uris?: [ 
        {
          configStatus?: string(name='configStatus', description='配置状态。值为 ACTIVE/MODIFIED/REMOVED'),
          gmtCreate?: long(name='gmtCreate', description='创建时间'),
          uriPrefix?: string(name='uriPrefix', description='URI前缀'),
          isUnit?: boolean(name='isUnit', description='是否单元化'),
        }
      ](name='uris', description='URI列表'),
      domainType?: string(name='domainType', description='域名类型，值为 单元化域名：unit，强中心域名：center'),
      managerType?: string(name='managerType', description='域名托管方式 ：DNS/GTM/EMPTY'),
    }
  ](name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model GetDomainAndUriResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: GetDomainAndUriResourcesResponseBody(name='body'),
}

async function getDomainAndUriResourcesWithOptions(request: GetDomainAndUriResourcesRequest, runtime: Util.RuntimeOptions): GetDomainAndUriResourcesResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = query,
  };
  return doRPCRequest('GetDomainAndUriResources', '2020-04-14', 'HTTPS', 'GET', 'AK', 'json', req, runtime);
}

async function getDomainAndUriResources(request: GetDomainAndUriResourcesRequest): GetDomainAndUriResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDomainAndUriResourcesWithOptions(request, runtime);
}

model OpenSpringCloudFlowItemRulesRequest {
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  ruleItemIds?: [ string ](name='ruleItemIds', description='ItemRule的ID'),
}

model OpenSpringCloudFlowItemRulesShrinkRequest {
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  ruleItemIdsShrink?: string(name='ruleItemIds', description='ItemRule的ID'),
}

model OpenSpringCloudFlowItemRulesResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data', description='推送计划的ID'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model OpenSpringCloudFlowItemRulesResponse = {
  headers: map[string]string(name='headers'),
  body: OpenSpringCloudFlowItemRulesResponseBody(name='body'),
}

async function openSpringCloudFlowItemRulesWithOptions(tmpReq: OpenSpringCloudFlowItemRulesRequest, runtime: Util.RuntimeOptions): OpenSpringCloudFlowItemRulesResponse {
  Util.validateModel(tmpReq);
  var request = new OpenSpringCloudFlowItemRulesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.ruleItemIds)) {
    request.ruleItemIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.ruleItemIds, 'ruleItemIds', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('OpenSpringCloudFlowItemRules', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function openSpringCloudFlowItemRules(request: OpenSpringCloudFlowItemRulesRequest): OpenSpringCloudFlowItemRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return openSpringCloudFlowItemRulesWithOptions(request, runtime);
}

model UpdateSpringCloudItemRulePriorityRequest {
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  effective?: boolean(name='Effective', description='是否立即生效'),
  priorities?: map[string]any(name='Priorities'),
}

model UpdateSpringCloudItemRulePriorityShrinkRequest {
  mshaTenantId?: string(name='MshaTenantId', description='多活命名空间'),
  effective?: boolean(name='Effective', description='是否立即生效'),
  prioritiesShrink?: string(name='Priorities'),
}

model UpdateSpringCloudItemRulePriorityResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data', description='推送计划的ID'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model UpdateSpringCloudItemRulePriorityResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateSpringCloudItemRulePriorityResponseBody(name='body'),
}

async function updateSpringCloudItemRulePriorityWithOptions(tmpReq: UpdateSpringCloudItemRulePriorityRequest, runtime: Util.RuntimeOptions): UpdateSpringCloudItemRulePriorityResponse {
  Util.validateModel(tmpReq);
  var request = new UpdateSpringCloudItemRulePriorityShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.priorities)) {
    request.prioritiesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.priorities, 'Priorities', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UpdateSpringCloudItemRulePriority', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function updateSpringCloudItemRulePriority(request: UpdateSpringCloudItemRulePriorityRequest): UpdateSpringCloudItemRulePriorityResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateSpringCloudItemRulePriorityWithOptions(request, runtime);
}

model UpdateSpringCloudFlowItemRuleRequest {
  requestData?: {
    itemRuleId?: long(name='itemRuleId', description='itemRuleID'),
    transportEnable?: boolean(name='transportEnable', description='是否开启染色'),
    priority?: long(name='priority', description='优先级'),
    name?: string(name='name', description='名称'),
    uriList?: [ string ](name='uriList', description='URI列表'),
    active?: boolean(name='active', description='是否生效，该规则在数据面是否生效'),
    queryMatcher?: [ 
      {
        key?: string(name='key', description='键值'),
        matchType?: string(name='matchType', description='匹配类型。in,notIn,between,>,>=,<,<=,='),
        values?: [ string ](name='values', description='值的集合'),
        extractType?: string(name='extractType', description='提取类型。mod,whole'),
        modValue?: long(name='modValue', description='模数'),
      }
    ](name='queryMatcher', description='Http query param匹配'),
    headerMatcher?: [ 
      {
        key?: string(name='key', description='键值'),
        matchType?: string(name='matchType', description='匹配类型。in,notIn,between,>,>=,<,<=,='),
        values?: [ string ](name='values', description='值的集合'),
        extractType?: string(name='extractType', description='提取类型。mod,whole'),
        modValue?: long(name='modValue', description='模数'),
      }
    ](name='headerMatcher', description='HTTP header匹配规则'),
    cellWeightList?: [ 
      {
        cellFlag?: string(name='cellFlag', description='单元格'),
        weight?: string(name='weight', description='引流比例,最多支持小数点后4位。0.0000～1.0000'),
      }
    ](name='cellWeightList'),
    effective?: boolean(name='effective', description='是否立即生效，MSHA将立即推送该规则'),
  }(name='requestData'),
}

model UpdateSpringCloudFlowItemRuleShrinkRequest {
  requestDataShrink?: string(name='requestData'),
}

model UpdateSpringCloudFlowItemRuleResponseBody = {
  total?: long(name='total'),
  code?: string(name='code'),
  requestId?: string(name='RequestId'),
  data?: long(name='data'),
  success?: boolean(name='success'),
  ip?: string(name='ip'),
  pageSize?: int32(name='pageSize'),
  message?: string(name='message'),
  currentPage?: int32(name='currentPage'),
  httpCode?: int32(name='httpCode'),
}

model UpdateSpringCloudFlowItemRuleResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateSpringCloudFlowItemRuleResponseBody(name='body'),
}

async function updateSpringCloudFlowItemRuleWithOptions(tmpReq: UpdateSpringCloudFlowItemRuleRequest, runtime: Util.RuntimeOptions): UpdateSpringCloudFlowItemRuleResponse {
  Util.validateModel(tmpReq);
  var request = new UpdateSpringCloudFlowItemRuleShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.requestData)) {
    request.requestDataShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.requestData, 'requestData', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UpdateSpringCloudFlowItemRule', '2020-04-14', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function updateSpringCloudFlowItemRule(request: UpdateSpringCloudFlowItemRuleRequest): UpdateSpringCloudFlowItemRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateSpringCloudFlowItemRuleWithOptions(request, runtime);
}

